home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / dobbs / v17n03 / oopasm.exe / KEYBOARD.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-03-18  |  2.3 KB  |  131 lines

  1.     .MODEL    SMALL
  2.  
  3.     INCLUDE    equates.inc
  4.     INCLUDE    instance.inc
  5.     INCLUDE    messages.inc
  6.     INCLUDE    objects.inc
  7.  
  8. IF1
  9.     INCLUDE    macros.mac
  10.     INCLUDE    objects.mac
  11.     INCLUDE    keyboard.mac
  12.     INCLUDE    strings.mac
  13. ENDIF
  14.  
  15.     EXTRN    Self:WORD
  16.  
  17.     .CODE
  18.  
  19. COMMENT    %
  20. ==============================================================================
  21. Gets the current keyboard shift status for display.
  22.  
  23. =============================================================================%
  24. disShiftStatus    PROC    NEAR
  25.     getInst        dh,Row1,Keyboard    ;Get status display row
  26.     getInst        dl,Col1            ;Get status display column
  27.     getInst        bl,Color        ;Get color
  28.  
  29.     getShiftStatus    ax            ;Get shift status
  30.  
  31.     push        ax
  32.     and        al,32
  33.     jz        dss1
  34.  
  35.     lea        si,Num
  36.     jmp        dss2
  37.  
  38. dss1:    lea        si,Off
  39. dss2:    call        disStatusString
  40.     pop        ax
  41.  
  42.     push        ax
  43.     and        al,128
  44.     jz        dss3
  45.  
  46.     lea        si,Ins
  47.     jmp        dss4
  48.  
  49. dss3:    lea        si,Off
  50. dss4:    call        disStatusString
  51.     pop        ax
  52.  
  53.     and        al,64
  54.     jz        dss5
  55.  
  56.     lea        si,Cap
  57.     jmp        dss6
  58.  
  59. dss5:    lea        si,Off
  60. dss6:    call        disStatusString
  61.     ret
  62. disShiftStatus    ENDP
  63.  
  64.  
  65.  
  66. COMMENT    %
  67. ==============================================================================
  68. Displays the specified shift status string.
  69.  
  70. Passed:    bl - Color
  71.     dx - Row/Column
  72.     es - Video segment addr
  73.     si - String addr
  74.  
  75. =============================================================================%
  76. disStatusString    PROC    NEAR
  77.     push        dx
  78.     disStrg        dh,dl,bl,si
  79.     pop        dx
  80.     inc        dh            ;Advance cursor to next line
  81.     ret
  82. disStatusString    ENDP
  83.  
  84.  
  85.  
  86. COMMENT    %
  87. ==============================================================================
  88. Reads a key event if available, and returns its Scan and ASCII codes.
  89.  
  90. =============================================================================%
  91. readKeyboard    PROC    NEAR
  92.     setInst        ScanCode,Nil,Keyboard,1    ;Clear scan code
  93.     ifNoKey        rdk1            ;No key event? - Exit
  94.     readKey        ah,al            ;Else - read key
  95.     setInst        ScanCode,ah        ;Save scan code
  96.     setInst        AsciiCode,al        ;Save ASCII code
  97. rdk1:    ret
  98. readKeyboard    ENDP
  99.  
  100.  
  101.  
  102.     .DATA
  103.  
  104. Cap    DB    " CapsLock ",0
  105. Ins    DB    " Insert   ",0
  106. Num    DB    " NumLock  ",0
  107. Off    DB    "          ",0
  108.  
  109. defMsg    KeyBoard,\
  110.     Read,\
  111.     <,,readKeyboard>
  112.  
  113. defMsg    KeyBoard,\
  114.     Refresh,\
  115.     <,,disShiftStatus>
  116.  
  117. defObj    KeyBoard,\
  118.     <>,\
  119.     <Row1,1,22,\
  120.     Col1,1,70,\
  121.     Row2,1,Nil,\
  122.     Col2,1,Nil,\
  123.     Color,1,31h,\
  124.     ScanCode,1,Nil,\
  125.     AsciiCode,1,Nil>,\
  126.     <Read,Refresh>
  127.  
  128.  
  129.  
  130.     END
  131.